package com.atguigu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyRedissonConfig {

    /**
     * 所有对Redisson的使用都是通过RedissonClien对象
     * @return
     * @throws IOException
     */
    @Bean
    public RedissonClient redisson() throws IOException{
        //1.创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://121.40.75.68:6379")
//        .setUsername("r-bp1r4nhfhd44bms2u0")
//        .setPassword("LINbo@15182")
        ;
        //2.根据Config创建出RedissonClient实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
